<template>
  <div class="app-container customermerchantsNew">
    <!--    <el-divider content-position="left">主要信息</el-divider>-->
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="主题名称" prop="clueName">
            <el-input v-model="form.clueName" placeholder="请输入主题名称"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="线索来源" prop="source">
            <el-select v-model="form.source" placeholder="请选择线索来源">
              <el-option
                v-for="dict in dict.type.source_type"
                :key="dict.value"
                :label="dict.label"
                :value="parseInt(dict.value)"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="客户名称" prop="companyName">
            <el-input v-model="form.companyName" placeholder="请输入客户名称"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户描述" prop="companyDesc">
            <el-input v-model="form.companyDesc" type="textarea" placeholder="请输入内容"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="Logo" prop="companyLogo">
<!--            <el-input v-model="form.companyLogo" placeholder="请输入"/>-->
            <imageUpload v-model="form.companyLogo"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="企业性质" prop="companyNature">
            <el-input v-model="form.companyNature" placeholder="请输入企业性质"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="所属行业" prop="industryname">
            <el-input v-model="form.industryname" placeholder="请输入所属行业"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="规模" prop="scale">
            <el-input v-model="form.scale" placeholder="请输入规模"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="联系人" prop="name">
            <el-input v-model="form.name" placeholder="请输入联系人"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="手机号" prop="mobile">
            <el-input v-model="form.mobile" placeholder="请输入手机号" maxlength="11"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="营业范围" prop="businessScope">
            <el-input v-model="form.businessScope" type="textarea" placeholder="请输入内容"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="注册资金" prop="registerMoney">
<!--            <el-input v-model="form.registerMoney" placeholder="请输入注册资金"/>-->
            <el-input-number v-model="form.registerMoney" :min="0"></el-input-number>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="法人" prop="legalPerson">
            <el-input v-model="form.legalPerson" placeholder="请输入法人"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="登记机关" prop="registrationAuthority">
            <el-input v-model="form.registrationAuthority" placeholder="请输入登记机关"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="注册时间" prop="registerTime">
            <el-date-picker clearable size="small"
                            v-model="form.registerTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择注册成立时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="状态" prop="status">
            <el-select v-model="form.status" placeholder="请选择状态">
              <el-option
                v-for="dict in dict.type.sys_normal_disable"
                :key="dict.value"
                :label="dict.label"
                :value="parseInt(dict.value)"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
<!--        <el-col :span="12">-->
<!--          <el-form-item label="分配人" prop="userId">-->
<!--            <el-input v-model="form.userId" placeholder="请输入分配人"/>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
        <el-col :span="12">
          <el-form-item label="描述" prop="remark">
            <el-input v-model="form.remark" placeholder="请输入描述"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="企业类型" prop="companyType">
            <el-select v-model="form.companyType" placeholder="请选择企业类型">
              <el-option
                v-for="dict in dict.type.company_type"
                :key="dict.value"
                :label="dict.label"
                :value="parseInt(dict.value)"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="注册地址" prop="companyAddress">
            <el-input v-model="form.companyAddress" placeholder="请输入注册地址"/>
          </el-form-item>
        </el-col>
      </el-row>

      <!--<el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="渠道分类" prop="reason">
            <el-select v-model="form.reason" filterable placeholder="请输入渠道分类" clearable size="small">
              <el-option
                v-for="dict in [1,2,3,4]"
                :key="dict"
                :label="dict"
                :value="dict"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="渠道名称" prop="remark">
            <el-input v-model="form.remark" placeholder="请输入渠道名称"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="详细描述" prop="remark">
            <el-input type="textarea" :rows="5" v-model="form.remark" placeholder="请输入详细描述"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider content-position="left">客户信息</el-divider>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="客户名称" prop="companyName">
            <el-input v-model="form.companyName" placeholder="请输入客户名称"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户类型" prop="reason">
            <el-select v-model="form.reason" filterable placeholder="请输入客户类型" clearable size="small">
              <el-option
                v-for="dict in [1,2,3,4]"
                :key="dict"
                :label="dict"
                :value="dict"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="证件号" prop="remark">
            <el-input v-model="form.remark" placeholder="请输入证件号"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属行业" prop="industryname">
            <el-input v-model="form.industryname" placeholder="请输入所属行业"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="联系人" prop="name">
            <el-input v-model="form.name" placeholder="请输入联系人"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="邮箱" prop="email">
            <el-input v-model="form.email" placeholder="请输入邮箱"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="联系电话" prop="mobile">
            <el-input v-model="form.mobile" placeholder="联系电话"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="通讯地址" prop="address">
            <el-input v-model="form.address" placeholder="请输入通讯地址"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="邮编" prop="remark">
            <el-input v-model="form.remark" placeholder="请输入邮编"/>
          </el-form-item>
        </el-col>
      </el-row>-->
      <el-form-item class="footer">
        <el-button @click="cancel">关闭</el-button>
        <el-button type="primary" @click="submitForm">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<style lang="scss">
  .app-main {
    background: #E7E7E7;
  }

  .app-container {
    margin: 15px;
    background: #fff;
    border-radius: 5px;
  }

  .customermerchantsNew {
    .el-divider {
      margin-bottom: 50px;

      .el-divider__text {
        font-size: 20px;
      }
    }

    .footer {
      display: flex;
      justify-content: center;
    }
  }
</style>
<script>
  import {
    addCustomermerchants,
    updateCustomermerchants
  } from "@/api/customermerchants/customermerchants";

  export default {
    name: "Contarct",
    dicts: ['sys_normal_disable', 'contarct_status', 'rent_month_type', 'unit_type','company_type','source_type'],
    data() {
      return {
        form: {},
        rules: {
          clueName: this.commonRequired("主题名称不能为空！"),
          companyName: this.commonRequired("客户名称不能为空！"),
          name: this.commonRequired("联系人不能为空！"),
          mobile: [{
            validator: this.conductionData.commonFun.checkPhone,
            trigger: 'blur',
            required: true,
          }],
          registerTime: this.commonRequired("注册时间不能为空！")
        }
      };
    },
    created() {
      // console.log(123);
      this.$nextTick(function () {
        if (this.$route.query.type === "update") {
          this.form = this.conductionData.customermerchantsdetails;
        }
        // console.log(this.form);
      })
    },
    destroyed() {
      this.conductionData.customermerchantsdetails = null;
    },
    methods: {
      commonRequired(value) {
        return this.conductionData.commonFun.commonRequired(value);
      },
      getList() {

      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              updateCustomermerchants(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.$router.go(-1);
              });
            } else {
              addCustomermerchants(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.$router.go(-1);
              });
            }
          }
        });
      },
      cancel() {
        this.$router.go(-1);
      }
    }
  };
</script>
